package com.uplooking.spider.task;

import com.uplooking.spider.constant.PageConstant;
import com.uplooking.spider.utils.DownLoadUtil;
import com.uplooking.spider.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 下载页面列表的任务
 */
@Component
public class PageListTask implements Runnable {

    @Autowired
    private DownLoadUtil downLoadUtil;

    @Autowired
    private PageUtil pageUtil;


    @Override
    public void run() {
        while (true) {
            //从redis中获取页码
            String currentPageNum = pageUtil.getCurrentPageNumAndSkipNextPage();
            //下载数据
            String html = downLoadUtil.download(PageConstant.PAGE_LIST_BASE_URL + currentPageNum);
            System.out.println(currentPageNum);
        }

    }
}
